<?php
/**
 * alltosun.com auth文件 auth_helper.php
 * ============================================================================
 * 版权所有 (C) 2009-2014 北京互动阳光科技有限公司，并保留所有权利。
 * 网站地址:   http://www.alltosun.com
 * ----------------------------------------------------------------------------
 * 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
 * ============================================================================
 * $Author: 张元昊 (zhangyh@alltosun.com) $
 * $Date: 2014-11-17 下午2:54:48 $
 * $Id$
*/
class auth_helper
{
    public static function returnAuthData($status,$line,$data=array())
    {
        $info['status'] = $status;
        if(D_BUG)
            $info['line'] = $line;
        $info['data'] = $data;
        echo json_encode($info);
        exit();
    }

    public static function returnMqbAuthData($data)
    {
        echo json_encode($data);
        exit();
    }

    //加密验证来源
    public static function getGen($randid, $appkey, $appskey)
    {
        return md5(md5($randid."appkey=".$appkey).$appskey);
    }

    //加密0r 失效
    public static function checkGen($randid, $appkey, $appskey, $key)
    {
        return (auth_helper::getGen($randid, $appkey, $appskey) == $key) && $randid+1800>=time() ;
    }


    //获得kv中存储的发送数据
    public static function getKvdata($mobile, $send_type)
    {
        $info = _model('mobile_code')->read(array('mobile' => $mobile, 'res_name' => $send_type), 'ORDER BY `id` DESC');
        return $info;
    }

    //激活邮箱
    public static function set_mail_send($email, $uid, $type, $code = '')
    {
        return user_helper::set_mail_send($email, $uid, $type, $code = '');
    }
    
}